package de.uni.muenster.idw2;

import java.util.ArrayList;

import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.widget.Toast;
import de.uni.muenster.idw2.data.BBBuilding;
import de.uni.muenster.idw2.db.DBHelper;
import de.uni.muenster.idw2.utilities.Utils;

public class StartScreen extends Activity {
	
 
	@Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.start_screen);
        
    }
    
    public void chooseBuilding(View view){
    	Intent intent = new Intent(this, BuildingChooserMap.class);
    	intent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
    	startActivity(intent);
    }
    
    public void lastBuildings(View view){
    	
    	
    	DBHelper dbHelper = new DBHelper(this);
    	ArrayList<BBBuilding> buildings = dbHelper.getBuildings();
    	dbHelper.closeDB();
//    	dbHelper.deleteDB();
    	
    	if(buildings.size() > 0){
    		Intent intent = new Intent(this, LastBuildingList.class);
        	intent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
        	intent.putExtra(Utils.BUILDING_INTENT_MSG, buildings);
        	startActivity(intent);
        	
        	
    	}
    	else{
    		Toast.makeText(this, "No Buildings Available", 4).show();
    	}
    	
    }
    
    public void aboutButton(View view){
    	String url = "http://indoor-wayfinding.uni-muenster.de/";
    	Intent i = new Intent(Intent.ACTION_VIEW);
    	i.setData(Uri.parse(url));
    	startActivity(i);

    }
    
    public void optionsButton(View view){
    	Intent intent = new Intent(this, Preferences.class);
    	intent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
    	startActivity(intent);
    }
}